{__NOLAYOUT__}
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="/agent/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="/agent/css/view_order.css"/>
    <link rel="stylesheet" type="text/css" href="/agent/css/my_dingdan.css"/>
    <script type="text/javascript" src="/agent/js/jquery.1.9.1.js" ></script>
    <script type="text/javascript" src="/agent/js/rem.js" ></script>
    <script type="text/javascript" src="/agent/js/mescroll.min.js" ></script>
    <link rel="stylesheet" type="text/css" href="/agent/css/mescroll.min.css"/>
    <title>查看订单</title>
</head>
<body>
<div class="top">
    <img src="{$agent.picture}"/>
    <p class="bookstore">{$agent.agent_name}</p>
</div>
<div class="sousuo">
    <input type="text" name="" id="sousuo" value="" placeholder="搜索订单号" />
    <img src="/agent/img/sousuo.png"/>
</div>
<div id="mescroll" class="my-address mescroll">
    <div id="orderList" class="address-list">

    </div>
</div>
</body>
<script>
  var offset = 0; //页码
  var limit = 10;  //每页数据固定条数
  var agentid = {$agent.id};
  var param = window.location.search;
  $('.sousuo').change(function () {
    offset = 0;
    limit = 10;
    param = $('#sousuo').val();
    $("#orderList div").remove();
    upCallback()
  });
  //创建MeScroll对象
  var mescroll = new MeScroll("mescroll", {
    up: {
      callback: upCallback //上拉加载的回调
      ,
      empty: {
        //列表第一页无任何数据时,显示的空提示布局; 需配置warpId或clearEmptyId才生效;
        warpId:'mescroll', //父布局的id; 如果此项有值,将不使用clearEmptyId的值;
        icon: null, //图标,默认null
        tip: "暂无新的数据~", //提示
        btntext: "", //按钮,默认""
        btnClick: null, //点击按钮的回调,默认null
      },
    }
  });
  //上拉加载的回调 page = {num:1, size:5}; num:当前页 默认从1开始, size:每页数据条数,默认5
  function upCallback(page) {
    $.ajax({
      url: '/admin/agent/info/mobileOrder/agentid/'+agentid+'?search='+param+'&offset='+offset+'&limit='+limit,
      dataType:'json',
      type:'GET',
      success: function(json) {
        offset += limit++;
        limit = 10;
        $('#orderList').append(render(json));
        mescroll.endByPage(json.rows.length, json.total);
      },
      error: function(e) {
        //联网失败的回调,隐藏下拉刷新和上拉加载的状态
        mescroll.endErr();
      }
    });
  }

  function render(data)
  {
    var html = '';
    $.each(data.rows,function (index,val) {
      html +='<ul class="single_item info""> \n' +
        '   <div class="order_list"> \n' +
        '    <h2> <span>订货单号：'+val.nb+'</span> <strong>'+val.createtime_text+'</strong> </h2> \n';
      $.each(val.item,function (i,v) {
        html +='     <div class="order_list_goods"> \n' +
          '      <dl> \n' +
          '       <dt> \n' +
          '        <img src="'+v.preproductimg_text+'" /> \n' +
          '       </dt> \n' +
          '       <dd class="name"> \n' +
          '        <strong>'+v.preproductname_text+'</strong> \n' +
          '       </dd> \n' +
          '       <dd class="pice"> '+v.unit_price +
          '        <em>x'+v.num+'</em>\n' +
          '       </dd> \n' +
          '      </dl> \n' +
          '     </div>\n' ;
      });
      html +='    <div class="pic">\n' +
        '     共'+val.item.length+'件商品&nbsp;&nbsp;合计：\n' +
        '     <strong>'+val.order_price+'</strong>\n' +
        '    </div> \n' + ' </div>' + ' </div> \n' + '  </ul> ';
    });
    return html;
  }
  $(function(){
    var myHeight = $(window).height();
    var topHeight = $('.top').height();
    var sousuoHeight = $('.sousuo').height()+parseInt($('.sousuo').css('padding-top'))+parseInt($('.sousuo').css('padding-bottom'));
    $(".mescroll").css('height',myHeight-topHeight-sousuoHeight);
  });
</script>
</html>

